package com.sf.protal.admin.controller;

import com.sf.protal.admin.pojo.UmsAdmin;
import com.sf.protal.admin.service.UmsUserService;
import com.sf.protal.common.utils.Msg;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@CrossOrigin
@Api(description = "用户操作")
public class UserController {

	@Autowired
	UmsUserService userService;

	@ApiOperation(value = "根据id查询用户" , notes="查询用户")
	@RequestMapping("/user/admin/{id}")
	public UmsAdmin getAdmin(Integer id){
		UmsAdmin admin = userService.getAdmin(id);
		return admin;
	}

	@ApiOperation(value = "用户登录" , notes="用户登录")
	@RequestMapping(value = "/login",method = RequestMethod.POST)
	public Msg UmsLogin(String username, String password){

		UmsAdmin user = userService.SelectUser(username,password);

		return Msg.success().add("user",user);
	}

}
